<div id="role_tb">
    <a href="#" onclick="add()" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加</a>
    <a href="#" onclick="edit()" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">编辑</a>
    <a href="#" onclick="del()" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
</div>
<table id="role_dg"></table>
<#include "/WEB-INF/views/include/common.ftl"/>
<script>
    var role_dg;
    $(function () {
        role_dg = $('#role_dg');
        role_dg.datagrid({
            url: '${ctx}/user/roleList',
            fitColumns: true,
            pagination: true,
            rownumbers: true,
            pageSize: 10,
            pageList: [10, 20, 30],
            idField: 'roleId',
            columns: [
                [{
                    field: 'roleId',
                    width: 100,
                    hidden: true,
                    title: 'id'
                }, {
                    field: 'roleName',
                    title: '角色',
                    width: 100
                }, {
                    field: 'description',
                    title: '描述',
                    width: 100
                }]
            ],
            toolbar: '#role_tb'
        });
    })

    <!--添加方法-->
    function add() {
        parent.$.modalDialog.openner = sysdict_dg;
        parent.$.modalDialog({
            title: "添加字典",
            width: 300,
            height: 300,
            href: "${ctx}/sys/addDictUI"
        });
    }
    <!--编辑方法-->
    function edit(){
        parent.$.modalDialog.openner = sysdict_dg;
        var selectrow = sysdict_dg.datagrid("getSelected");
        if(selectrow == null){
            $.messager.show({
                title : '提示信息',
                msg : '请选择一条记录',
                timeout : 1000 * 2
            });
            return false;
        }
        parent.$.modalDialog({
            title: "编辑字典",
            width: 300,
            height: 300,
            href: "${ctx}/sys/editDictUI/"+selectrow.dict_id
        });
    }

    <!--删除方法-->
    function del(){
        var selectrow = sysdict_dg.datagrid("getSelected");
        if(selectrow == null){
            $.messager.show({
                title : '提示信息',
                msg : '请选择一条记录',
                timeout : 1000 * 2
            });
            return false;
        }

        $.get("${ctx}/sys/delDict/"+selectrow.dict_id,function(data){
            sysdict_dg.datagrid("reload");
            $.messager.show({
                title : '提示信息',
                msg : '操作成功',
                timeout : 1000 * 2
            });
         })
    }
</script>